#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

void main(int argc, char* argv[])
{
    char buf[1];
    int fd = open("/dev/led_dev", O_RDWR);
    if (fd < 0){
        printf("open /dev/led_dev failed! \n");
        return;
    }

    if (*argv[1] == 'w'){
        if (*argv[2] == '0'){
            buf[0] = 0;
        }else{
            buf[0] = 1;
        }
        write(fd, buf, 1);
    } else{
        read(fd, buf, 1);
    }

    close(fd);
}